package cn.lili.modules.entity;

import java.io.Serializable;

import cn.lili.common.utils.StringUtils;
import cn.lili.modules.dto.PublisherDTO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;
import com.baomidou.mybatisplus.annotation.TableName;

/**
 * <p>
 * 视频信息表
 * </p>
 *
 * @author liuyang
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName("app_videos_ceshi")
@ApiModel(value = "AppVideosCeshi", description = "视频信息表")
public class AppVideosCeshi implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "主键")
    @TableId(type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty(value = "发布者id")
    private String user_id;

    @ApiModelProperty(value = "视频描述")
    private String video_desc;

    @ApiModelProperty(value = "视频存放的路径")
    private String video_path;

    @ApiModelProperty(value = "视频秒数")
    private Integer video_seconds;

    @ApiModelProperty(value = "视频封面图")
    private String cover_path = "";

    @ApiModelProperty(value = "喜欢/赞美的数量")
    private Integer like_counts = 0;

    @ApiModelProperty(value = "发布成功\\r\\n2、禁止播放，管理员操作   3.入库中")
    private Integer status = 3;

    @ApiModelProperty(value = "创建时间")
    private Integer create_time;

    @ApiModelProperty(value = "视频id")
    private String fileid;
    private String contents;

    @ApiModelProperty(value = "0 正常 1 禁止")
    private Integer prohibit;
    private String goods_name;
    private String goods_price;
    private String goods_img;
    private String goods_url;
    private String adv_name;
    private String adv_url;
    private Integer price = 0;
    private Integer is_save = 0;
    private Integer sort = 0;
    private Integer pay_type = 0;
    private Integer givesum = 0;
    private Integer commentssum = 0;
    private Integer collectsum = 0;
    private Integer sharecount = 0;
    private Integer pay_count = 0;
    private Integer is_comment = 10;
    private String goods_id;
    private String distribution_id;
    private String sku_id;
    private Integer gift_count = 0;

    @ApiModelProperty(value = "专辑ID")
    private Integer album_id;

    @ApiModelProperty(value = "专辑名称")
    private String album_name;

    @ApiModelProperty(value = "频道ID")
    private String label_id;

    @TableField(exist = false)
    @ApiModelProperty(value = "页号")
    private Integer page = 1;

    @TableField(exist = false)
    @ApiModelProperty(value = "页面大小")
    private Integer page_size = 4;

    @TableField(exist = false)
    private String token;

    @ApiModelProperty(value = "外链ID")
    @TableField(exist = false)
    private Integer outside_id;

    @ApiModelProperty(value = "获取视频ID")
    @TableField(exist = false)
    private Integer nextVideoId;

    @ApiModelProperty(value = "是否关注")
    @TableField(exist = false)
    private Integer users_fans;

    @ApiModelProperty(value = "是否点赞")
    @TableField(exist = false)
    private Integer give;

    @ApiModelProperty(value = "是否收藏")
    @TableField(exist = false)
    private Integer shoucang;

    @TableField(exist = false)
    PublisherDTO publisher;

    /**
     * 短剧id
     */
    private String ad_video_id;

    /**
     * 构建查询对象
     *
     * @return 查询条件
     */
    public LambdaQueryWrapper<AppVideosCeshi> wrapper(String openId) {
        return new LambdaQueryWrapper<AppVideosCeshi>()
                .like(StringUtils.isNotEmpty(goods_name), AppVideosCeshi::getGoods_name, goods_name)
                .eq(StringUtils.isNotEmpty(label_id), AppVideosCeshi::getLabel_id, label_id)
                .eq(AppVideosCeshi::getStatus, 1)
                .lt(nextVideoId != -1, AppVideosCeshi::getId, nextVideoId)
                .notInSql(StringUtils.isNotEmpty(openId), AppVideosCeshi::getId, "SELECT video_id FROM app_videos_view WHERE user_id = '" + openId + "'")
                .orderByDesc(AppVideosCeshi::getCreate_time);
    }

    public LambdaQueryWrapper<AppVideosCeshi> wrapper2(String openId) {
        return new LambdaQueryWrapper<AppVideosCeshi>()
                .like(StringUtils.isNotEmpty(goods_name), AppVideosCeshi::getGoods_name, goods_name)
                .eq(StringUtils.isNotEmpty(label_id), AppVideosCeshi::getLabel_id, label_id)
                .eq(AppVideosCeshi::getStatus, 1)
                .lt(nextVideoId != -1, AppVideosCeshi::getId, nextVideoId)
                .orderByDesc(AppVideosCeshi::getCreate_time);
    }
}
